home *** CD-ROM | disk | FTP | other *** search
Text File | 1992-03-04 | 13.5 KB | 458 lines | [TEXT/PJMM] |
- unit Configure;
-
- interface
-
- uses
- Globals, StringFunctions, TextUtils;
-
- procedure FrameDItem (dLog: DialogPtr; iNum: integer);
- function ButtonSelected (whichDialog: DialogPtr; whichItem: integer): boolean;
- procedure ReadDefaults;
- procedure WriteResources (Defaults: Settings);
- function Configure (var newDefaults: Settings): boolean;
-
- implementation
-
- {----------------------------------------------------------------- }
-
- procedure FrameDItem; {(dLog: DialogPtr; iNum: integer)}
-
- var
- iBox: Rect;
- iType: integer;
- iHandle: Handle;
- oldPenState: PenState;
-
- begin
- GetPenState(oldPenState);
- GetDItem(dLog, iNum, iType, iHandle, iBox);
- InsetRect(iBox, -4, -4);
- PenSize(3, 3);
- FrameRoundRect(iBox, 16, 16);
- SetPenState(oldPenState)
- end;
-
- {----------------------------------------------------------------- }
-
- function ButtonSelected; {(whichDialog: DialogPtr; whichItem: integer): boolean;}
-
- var
- whichType: integer;
- whichHandle: handle;
- whichRect, displayRect: rect;
- mouseLoc: point;
- DelayTime: longint;
- nowInverted: boolean;
-
- begin
- getDItem(whichDialog, whichItem, whichType, whichHandle, whichRect);
- displayRect := whichRect;
- InsetRect(displayRect, 1, 1);
- InvertRect(displayRect);
- nowInverted := true;
- if StillDown then
- repeat
- GetMouse(mouseLoc);
- if PtInRect(mouseLoc, whichRect) then
- begin
- if not nowInverted then
- begin
- InvertRect(displayRect);
- nowInverted := true
- end
- end
- else
- begin
- if nowInverted then
- begin
- InvertRect(displayRect);
- nowInverted := false
- end
- end
- until not StillDown;
- if nowInverted then
- begin
- Delay(4, DelayTime);
- InvertRect(displayRect);
- end;
- ButtonSelected := nowInverted
- end;
-
- {----------------------------------------------------------------- }
-
- procedure ReadDefaults;
-
- { _________Resource_notes__________ }
- { STR# 128 holds report settings as follows: }
- { #1 two-character string with Call symbol and NoCall symbol }
- { #2 title string: BBS activity from ^0 to ^1 }
- { #3 summary: ^0 Graphic Interface calls, ^1 Command Line Interface calls, ^2 total }
- { #4 Header file name }
- { #5 "Line" }
- { #6 "time used" }
- { #7 "Connection speeds" }
- { #8 "Registrations" }
- { #9 "Name Calls Time" }
- { #10 "Total" }
- { #11 Sessions to omit, comma separated }
- { Can contain up to 10 session numbers }
- { #12 TEXT file signature }
- { STR# 129 holds log prompts as follows: }
- { #1 " Start " }
- { #2 " Command Line " }
- { #3 " Session Ended. " }
- { #4 " auto-registered Sess " }
- { STR# 130 holds paths & misc info as follows: }
- { #1 Path to FC daily logs }
- { #2 Path of brief report file }
- { #3 Name of brief report file }
- { #4 Defaults [1] = MultiFinder, [2] = Automatic, [3] = Big Report, [4] = Brief Report }
- { #5 Special line to track }
-
- var
- tempString, numString: str255;
- Err: OSErr;
- HeaderRef, counter: integer;
- HowManyChars, tempLong: longint;
-
- begin
- GetIndString(tempString, 128, 1);
- callSymbol := tempString[1];
- noCallSymbol := tempString[2];
- GetIndString(TitleString, 128, 2);
- GetIndString(SummaryString, 128, 3);
- GetIndString(HeaderFileName, 128, 4);
- Err := FSOpen(HeaderFileName, vRefNum, HeaderRef);
- if Err = NoErr then
- Err := GetEOF(HeaderRef, HowManyChars);
- if Err = NoErr then
- begin
- if (HowManyChars > 255) then
- HowManyChars := 255;
- Err := FSRead(HeaderRef, HowManyChars, Pointer(ord(@LegendString) + 1));
- LegendString[0] := char(HowManyChars)
- end
- else
- LegendString := '';
- Err := FSClose(HeaderRef);
- GetIndString(LineTitle, 128, 5);
- GetIndString(TimeUsedTitle, 128, 6);
- GetIndString(ConnectionSpeedsTitle, 128, 7);
- GetIndString(RegistrationsTitle, 128, 8);
- GetIndString(NameCallsTimeTitle, 128, 9);
- GetIndString(TotalTitle, 128, 10);
- GetIndString(tempString, 128, 11);
- HowManyOmits := 0;
- for counter := 1 to IGNORES do
- Defaults.IgnoreSess[counter] := -1;
- while pos(',', tempString) > 0 do
- begin
- numString := copy(tempString, 1, pos(',', tempString) - 1);
- HowManyOmits := succ(HowManyOmits);
- Defaults.IgnoreSess[HowManyOmits] := GetValue(numString);
- tempString := copy(tempString, pos(',', tempString) + 1, 255);
- end;
- if tempString <> '' then
- begin
- HowManyOmits := succ(HowManyOmits);
- Defaults.IgnoreSess[HowManyOmits] := GetValue(tempString)
- end;
- GetIndString(tempString, 128, 12);
- Defaults.Creator := copy(tempString, 1, 4);
- GetIndString(gSessStart, 129, 1);
- GetIndString(gCommandLine, 129, 2);
- GetIndString(gSessionEnd, 129, 3);
- GetIndString(gAutoRegister, 129, 4);
- GetIndString(Defaults.FCLogPath, 130, 1);
- GetIndString(Defaults.BriefPath, 130, 2);
- GetIndString(Defaults.BriefName, 130, 3);
- GetIndString(tempString, 130, 4);
- if tempString[1] = 'Y' then
- Defaults.MFinder := true
- else
- Defaults.MFinder := false;
- if tempString[2] = 'Y' then
- Defaults.Automatic := true
- else
- Defaults.Automatic := false;
- if tempString[3] = 'Y' then
- Defaults.DoBriefRept := true
- else
- Defaults.DoBriefRept := false;
- GetIndString(tempString, 130, 5);
- StringToNum(tempString, tempLong);
- Defaults.SpecialSess := integer(tempLong);
- end;
-
- {----------------------------------------------------------------- }
-
- procedure ToggleButton (var State: boolean; theDialog: DialogPtr; ItemHit: integer);
-
- var
- itemType: integer;
- itemHandle: handle;
- dispRect: rect;
- thisButton: ControlHandle;
-
- begin
- State := not State;
- getDItem(theDialog, ItemHit, itemType, itemHandle, dispRect);
- thisButton := ControlHandle(itemHandle);
- if State then
- SetCtlValue(thisButton, 1)
- else
- SetCtlValue(thisButton, 0)
- end;
-
- {----------------------------------------------------------------- }
-
- procedure MakePath (FName: STR255; VRefNum: integer; var MyPath: STR255);
-
- var
- MyPB: CInfoPBRec;
- Err: OSErr;
-
- begin
- MyPath := '';
- MyPB.ioCompletion := nil;
- MyPB.ioNamePtr := @FName;
- MyPB.ioVRefNum := VRefNum;
- MyPB.ioFDirIndex := 0;
- MyPB.ioDirID := 0;
- Err := PBGetCatInfo(@MyPB, false);
- MyPB.ioFDirIndex := -1;
- MyPB.ioDirID := MyPB.ioDRParID;
- while PBGetCatInfo(@MyPB, false) = NoErr do
- begin
- MyPath := concat(MyPB.ioNamePtr^, ':', MyPath);
- MyPB.ioDirID := MyPB.ioDRParID;
- MyPB.ioFDirIndex := -1;
- end; { while PBGetCatInfo(@MyPB, false) = NoErr }
- end;
-
- { ------------------------------------------------------ }
-
- procedure WriteResources; {(Defaults: Settings)}
-
- { STR# 128 holds report settings as follows: }
- { #11 Sessions to omit, comma separated }
- { Can contain up to 10 session numbers }
- { #12 TEXT file signature }
- { STR# 130 holds paths & misc info as follows: }
- { #1 Path to FC daily logs }
- { #2 Path of brief report file }
- { #3 Name of brief report file }
- { #4 Defaults [1] = MultiFinder, [2] = Automatic, [3] = Big Report, [4] = Brief Report }
-
- var
- Err: OSErr;
- tempString: str255;
- count: integer;
-
- begin
- Err := SetIndString(130, 1, Defaults.FCLogPath);
- Err := SetIndString(130, 2, Defaults.BriefPath);
- Err := SetIndString(130, 3, Defaults.BriefName);
- tempString := 'YYY';
- if not Defaults.MFinder then
- tempString[1] := 'N';
- if not Defaults.Automatic then
- tempString[2] := 'N';
- if not Defaults.DoBriefRept then
- tempString[3] := 'N';
- Err := SetIndString(130, 4, tempString);
- tempString := '';
- for count := 1 to 12 do
- if (Defaults.IgnoreSess[count] > 0) then
- tempString := concat(tempString, ValueToString(Defaults.IgnoreSess[count]), ',')
- else if (Defaults.IgnoreSess[count] = 0) then
- tempString := concat(tempString, '0,');
- if tempString[length(tempString)] = ',' then
- tempString := copy(tempString, 1, length(tempString) - 1);
- Err := SetIndString(130, 5, StringOf(Defaults.SpecialSess : 0));
- Err := SetIndString(128, 11, tempString);
- Err := SetIndString(128, 12, Defaults.Creator);
- UpdateResFile(CurResFile)
- end;
-
- { ------------------------------------------------------ }
-
- function Configure; {(var newDefaults: Settings): boolean}
-
- var
- ItemHit, itemType, whichItem, count: integer;
- tempString, Location: str255;
- itemHandle: Handle;
- dispRect: Rect;
- thisButton: ControlHandle;
- where: point;
- fileReply: SFReply;
- whatToFind: SFTypeList;
- theDialog: DialogPtr;
- Err: OSErr;
- tempLong: longint;
-
- procedure FlashButton (WhichButton: integer);
-
- var
- DelayTime: longint;
-
- begin
- getDItem(theDialog, WhichButton, itemType, itemHandle, dispRect);
- InsetRect(dispRect, 1, 1);
- InvertRect(dispRect);
- if StillDown then
- repeat
- until not Button
- else
- Delay(4, DelayTime);
- Delay(4, DelayTime)
- end;
-
- begin
- Configure := false;
- InitCursor;
- ParamText(VERSION, '', '', '');
- theDialog := GetNewDialog(500, nil, POINTER(-1));
- SetPort(theDialog);
- FrameDItem(theDialog, Ok);
-
- getDItem(theDialog, 3, itemType, itemHandle, dispRect);
- SetIText(itemHandle, newDefaults.FCLogPath);
-
- getDItem(theDialog, 4, itemType, itemHandle, dispRect);
- SetIText(itemHandle, newDefaults.BriefPath);
-
- getDItem(theDialog, 5, itemType, itemHandle, dispRect);
- SetIText(itemHandle, newDefaults.BriefName);
-
- getDItem(theDialog, 6, itemType, itemHandle, dispRect);
- SetIText(itemHandle, newDefaults.Creator);
-
- for count := 1 to HowManyOmits do
- begin
- getDItem(theDialog, count + 6, itemType, itemHandle, dispRect);
- SetIText(itemHandle, ValueToString(newDefaults.IgnoreSess[count]))
- end;
-
- getDItem(theDialog, 21, itemType, itemHandle, dispRect);
- thisButton := ControlHandle(itemHandle);
- if newDefaults.MFinder then
- SetCtlValue(thisButton, 1)
- else
- SetCtlValue(thisButton, 0);
-
- getDItem(theDialog, 22, itemType, itemHandle, dispRect);
- thisButton := ControlHandle(itemHandle);
- if newDefaults.Automatic then
- SetCtlValue(thisButton, 1)
- else
- SetCtlValue(thisButton, 0);
-
- getDItem(theDialog, 23, itemType, itemHandle, dispRect);
- thisButton := ControlHandle(itemHandle);
- if newDefaults.DoBriefRept then
- SetCtlValue(thisButton, 1)
- else
- SetCtlValue(thisButton, 0);
-
- getDItem(theDialog, 31, itemType, itemHandle, dispRect);
- SetIText(itemHandle, StringOf(NewDefaults.SpecialSess : 0));
-
- repeat
- ModalDialog(nil, ItemHit);
-
- case ItemHit of
- 1: { OK button hit, save settings }
- begin
- Configure := true;
- getDItem(theDialog, 3, itemType, itemHandle, dispRect);
- GetIText(itemHandle, newDefaults.FCLogPath);
- getDItem(theDialog, 4, itemType, itemHandle, dispRect);
- GetIText(itemHandle, newDefaults.BriefPath);
- getDItem(theDialog, 5, itemType, itemHandle, dispRect);
- GetIText(itemHandle, newDefaults.BriefName);
- getDItem(theDialog, 6, itemType, itemHandle, dispRect);
- GetIText(itemHandle, tempString);
- while length(tempString) < 4 do
- tempString := concat(tempString, ' ');
- newDefaults.Creator := copy(tempString, 1, 4);
- for count := 1 to 12 do
- begin
- getDItem(theDialog, count + 6, itemType, itemHandle, dispRect);
- GetIText(itemHandle, tempString);
- if length(tempString) > 0 then
- newDefaults.IgnoreSess[count] := GetValue(tempString)
- else
- newDefaults.IgnoreSess[count] := -1
- end;
- getDItem(theDialog, 31, itemType, itemHandle, dispRect);
- GetIText(itemHandle, tempString);
- StringToNum(tempString, tempLong);
- newDefaults.SpecialSess := integer(tempLong)
- end;
-
- 2:
- ; { Cancel button hit—do nothing }
-
-
- 7..18:
- ;
-
- 19:
- if ButtonSelected(theDialog, 19) then
- begin { Look Up Log Path button }
- FlashButton(19);
- InvertRect(dispRect);
- where.h := 60;
- where.v := 80;
- SFPPutFile(where, 'Please select location ', 'test.$', nil, fileReply, 600, nil);
- if fileReply.good then
- begin
- Err := Create(fileReply.fname, fileReply.vRefNum, 'QED1', 'TEXT');
- MakePath(fileReply.fname, fileReply.vRefNum, Location);
- Err := FSDelete(fileReply.fname, fileReply.vRefNum);
- getDItem(theDialog, 3, itemType, itemHandle, dispRect);
- SetIText(itemHandle, Location)
- end;
- FrameDItem(theDialog, Ok)
- end;
-
- 20:
- if ButtonSelected(theDialog, 20) then
- begin { Look Up Brief Path button }
- FlashButton(20);
- InvertRect(dispRect);
- where.h := 60;
- where.v := 80;
- SFPPutFile(where, 'Please select location ', 'test.$', nil, fileReply, 600, nil);
- if fileReply.good then
- begin
- Err := Create(fileReply.fname, fileReply.vRefNum, 'QED1', 'TEXT');
- MakePath(fileReply.fname, fileReply.vRefNum, Location);
- Err := FSDelete(fileReply.fname, fileReply.vRefNum);
- getDItem(theDialog, 4, itemType, itemHandle, dispRect);
- SetIText(itemHandle, Location)
- end;
- FrameDItem(theDialog, Ok)
- end;
-
- 21:
- ToggleButton(newDefaults.MFinder, theDialog, ItemHit);
-
- 22:
- ToggleButton(newDefaults.Automatic, theDialog, ItemHit);
-
- 23:
- ToggleButton(newDefaults.DoBriefRept, theDialog, ItemHit);
-
- otherwise
- ;
- end;{case}
-
- until (ItemHit = 1) | (ItemHit = 2);
-
- DisposDialog(theDialog);
- end;
-
- end.